package com.stdio.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class timeformat 
{
	public static String getTimeformat(Date date)
	{
		String str = "";
		SimpleDateFormat sdf;
		Calendar now = Calendar.getInstance();
		Date time = now.getTime();
		int flag = date.compareTo(time);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int day1 = calendar.get(Calendar.DAY_OF_MONTH);
		int day2 = now.get(Calendar.DAY_OF_MONTH);
		
        if(flag < 0)
        {
        	if(day1-day2 ==1)
        	{
        		str = "yestoday";
        	}
        	
        	sdf = new SimpleDateFormat("MM/DD");
        	String passedtime = sdf.format(date);
        	str = passedtime;
        }else if(flag == 0){
        	sdf = new SimpleDateFormat("HH:mm");
    		String currenttime = sdf.format(time);
            
        	str = currenttime;
        }
		
		return str;
	}
	
}
